package cn.t.web.industry;

import cn.t.core.mode.Result;
import cn.t.facade.industry.IndustryWorkOrderFacade;
import cn.t.request.industry.IndustryCreateWorkOrderReq;
import cn.t.vo.industry.IndustryApplyOrderVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *  - 留资领取礼品
 */
@Slf4j
@RestController
@RequestMapping("/industry/workOrder")
@AllArgsConstructor
public class IndustryWorkOrderController {

    private final IndustryWorkOrderFacade industryWorkOrderFacade;

    /**
     * 创建工单接口
     */
    @PostMapping("/create")
    public Result<String> createWorkOrder(@Validated @RequestBody IndustryCreateWorkOrderReq request) {
        String workOrderSn = this.industryWorkOrderFacade.createWorkOrder(request);
        return Result.success(workOrderSn);
    }

    /**
     * 现场看板-最新领用领用申请查询接口
     */
    @GetMapping("/apply")
    public List<IndustryApplyOrderVO> getApplyOrder(@RequestParam Integer count, @RequestParam(required = false) Long firmId) {
        return industryWorkOrderFacade.getApplyOrder(count, firmId);
    }

}

